package fr.grassaud.hmvc.session;

import java.util.Set;

import fr.grassaud.hmvc.event.HMVCEvent;

public interface HMVCSession {

    /**
     * Sends a <code>ViewEvent</code>. Assures that the sender is well a view component
     * @param sender the sender of the event
     * @param event the event to send
     */
     boolean  sendViewEvent(Object sender, HMVCEvent event);
    
    /**
     * Sends a <code>ModelEvent</code>. Assures that the sender is well a model component
     * @param sender the sender of the event
     * @param event the event to send
     */
     boolean sendModelEvent(Object sender, HMVCEvent event);
    
    /**
     * Sends a <code>ControllerEvent</code>. assures that the sender is well a controller component
     * @param sender the sender of the event
     * @param event the event to send
     */
     boolean sendControllerEvent(Object sender, HMVCEvent event);
     
     /**
      * Returns the attribute from this session with the given name
      * @param name the name of the attribute to get
      * @return the object corresponding to the given attribute name, or <code>null</code> if none
      */
      <T> T getAttribute(String name);
     
     /**
      * Removes the attribute with the given name from this session
      * @param name the name of the attribute to remove
      */
      void removeAttribute(String name);
      
      
      /**
       * Adds a new attributes to this session
       * @param name the name of the attribute to add
       * @param object the value of the attribute to add
       */
       void addAttribute(String name, Object object);
      
      /**
       * Returns all attributes names of this session
       * @return all attributes names of this session
       */
       Set<String> getAttributeNames();
      
      /**
       * Returns the main view of this session
       * @return the main view of this session
       */
       <T> T getMainView();
       
       /**
        * Returns the class of the root controller of this session
        * The class should be annotated with the <code>Controller</code> annotation
        * @return the class of the root controller of this session
        */
       Class<?> getRootControllerClass();
    
       
       String getId();
       
       /**
        * Adds the given triad listener to this session
        * @param listener the listener to add
        */
       public void addTriadListener(TriadListener listener);
       
       /**
        * Removes the given triad listener from this session
        * @param listener the listener to remove
        */
       public void removeTriadListener(TriadListener listener);
}
